/*
7 Segment alarm clock by Ben Surtees
All text must be written in CAPITALS to get write ascii code
Uses 4 7 segments.
*/
#include "defines.h"
#include "SevenSegmentArrays.h"
#include "Globals.h"
#include "Texts.h"

void setup() {
  randomSeed(432423);//randomSeed(analogRead(openAnalogPin));
  Serial.begin(9600);
  blinkLED(buzzerPin, 4, 100); // blink an LED at the start of the program, to show the code is running
  pinMode(leftInput, INPUT); //pins for normally closed switches to set the time
  pinMode(rightInput, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(segA, OUTPUT);
  pinMode(segB, OUTPUT);
  pinMode(segC, OUTPUT);
  pinMode(segD, OUTPUT);
  pinMode(segE, OUTPUT);
  pinMode(segF, OUTPUT);
  pinMode(segG, OUTPUT);
  pinMode(segDp, OUTPUT);
  pinMode(seg1, OUTPUT);
  pinMode(seg2, OUTPUT);
  pinMode(seg3, OUTPUT);
  pinMode(seg4, OUTPUT);
  
  digitalWrite(13, LOW);
  //digitalWrite(buzzerPin, HIGH);
  
  //digitalWrite(seg1, HIGH);
  //digitalWrite(seg2, HIGH);
  //digitalWrite(seg3, HIGH);
  //digitalWrite(seg4, HIGH);
  
  //delay(1000);
}

bool wroteOnce;
void loop()
{
   
  if(!wroteOnce)
  {
    wroteOnce = WriteText("HELLO JACQ BEN LOVES YOU LOTS", 28);//
  }
  
  Clock();
  
  GetInputs ();
  
  Alarm();

  Menu();

  Draw();
}

// this utility function blinks the an LED light as many times as requested
void blinkLED(byte targetPin, int numBlinks, int blinkRate) {
  for (int i=0; i < numBlinks; i++) {
    digitalWrite(targetPin, HIGH); // sets the LED on
    delay(blinkRate); // waits for a blinkRate milliseconds
    digitalWrite(targetPin, LOW); // sets the LED off
    delay(blinkRate);
  }
}
